.class public Lcom/qiniu/auth/Client;
.super Ljava/lang/Object;
.source "Client.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/qiniu/auth/Client$ClientExecutor;
    }
.end annotation


# instance fields
.field protected mClient:Lorg/apache/http/client/HttpClient;


# direct methods
.method public constructor <init>(Lorg/apache/http/client/HttpClient;)V
    .registers 2
    .param p1, "client"    # Lorg/apache/http/client/HttpClient;

    .prologue
    .line 27
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 28
    iput-object p1, p0, Lcom/qiniu/auth/Client;->mClient:Lorg/apache/http/client/HttpClient;

    .line 29
    return-void
.end method

.method public static defaultClient()Lcom/qiniu/auth/Client;
    .registers 2

    .prologue
    .line 128
    new-instance v0, Lcom/qiniu/auth/Client;

    invoke-static {}, Lcom/qiniu/auth/Client;->getMultithreadClient()Lorg/apache/http/client/HttpClient;

    move-result-object v1

    invoke-direct {v0, v1}, Lcom/qiniu/auth/Client;-><init>(Lorg/apache/http/client/HttpClient;)V

    return-object v0
.end method

.method public static get(Ljava/lang/String;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;
    .registers 4
    .param p0, "url"    # Ljava/lang/String;
    .param p1, "ret"    # Lcom/qiniu/auth/CallRet;

    .prologue
    .line 32
    invoke-static {}, Lcom/qiniu/auth/Client;->defaultClient()Lcom/qiniu/auth/Client;

    move-result-object v0

    .line 33
    .local v0, "client":Lcom/qiniu/auth/Client;
    invoke-virtual {v0}, Lcom/qiniu/auth/Client;->makeClientExecutor()Lcom/qiniu/auth/Client$ClientExecutor;

    move-result-object v1

    invoke-virtual {v0, v1, p0, p1}, Lcom/qiniu/auth/Client;->get(Lcom/qiniu/auth/Client$ClientExecutor;Ljava/lang/String;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;

    move-result-object v1

    return-object v1
.end method

.method public static getMultithreadClient()Lorg/apache/http/client/HttpClient;
    .registers 5

    .prologue
    .line 132
    new-instance v0, Lorg/apache/http/impl/client/DefaultHttpClient;

    invoke-direct {v0}, Lorg/apache/http/impl/client/DefaultHttpClient;-><init>()V

    .line 133
    .local v0, "client":Lorg/apache/http/client/HttpClient;
    invoke-interface {v0}, Lorg/apache/http/client/HttpClient;->getConnectionManager()Lorg/apache/http/conn/ClientConnectionManager;

    move-result-object v1

    .line 134
    .local v1, "mgr":Lorg/apache/http/conn/ClientConnectionManager;
    invoke-interface {v0}, Lorg/apache/http/client/HttpClient;->getParams()Lorg/apache/http/params/HttpParams;

    move-result-object v2

    .line 135
    .local v2, "params":Lorg/apache/http/params/HttpParams;
    new-instance v0, Lorg/apache/http/impl/client/DefaultHttpClient;

    .end local v0    # "client":Lorg/apache/http/client/HttpClient;
    new-instance v3, Lorg/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager;

    invoke-interface {v1}, Lorg/apache/http/conn/ClientConnectionManager;->getSchemeRegistry()Lorg/apache/http/conn/scheme/SchemeRegistry;

    move-result-object v4

    invoke-direct {v3, v2, v4}, Lorg/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager;-><init>(Lorg/apache/http/params/HttpParams;Lorg/apache/http/conn/scheme/SchemeRegistry;)V

    invoke-direct {v0, v3, v2}, Lorg/apache/http/impl/client/DefaultHttpClient;-><init>(Lorg/apache/http/conn/ClientConnectionManager;Lorg/apache/http/params/HttpParams;)V

    .line 136
    .restart local v0    # "client":Lorg/apache/http/client/HttpClient;
    return-object v0
.end method


# virtual methods
.method public call(Lcom/qiniu/auth/Client$ClientExecutor;Ljava/lang/String;Ljava/lang/String;Lorg/apache/http/HttpEntity;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;
    .registers 8
    .param p1, "client"    # Lcom/qiniu/auth/Client$ClientExecutor;
    .param p2, "url"    # Ljava/lang/String;
    .param p3, "contentType"    # Ljava/lang/String;
    .param p4, "entity"    # Lorg/apache/http/HttpEntity;
    .param p5, "ret"    # Lcom/qiniu/auth/CallRet;

    .prologue
    .line 46
    new-instance v0, Lorg/apache/http/client/methods/HttpPost;

    invoke-direct {v0, p2}, Lorg/apache/http/client/methods/HttpPost;-><init>(Ljava/lang/String;)V

    .line 47
    .local v0, "httppost":Lorg/apache/http/client/methods/HttpPost;
    invoke-virtual {v0, p4}, Lorg/apache/http/client/methods/HttpPost;->setEntity(Lorg/apache/http/HttpEntity;)V

    .line 49
    if-eqz p3, :cond_f

    .line 50
    const-string v1, "Content-Type"

    invoke-virtual {v0, v1, p3}, Lorg/apache/http/client/methods/HttpPost;->setHeader(Ljava/lang/String;Ljava/lang/String;)V

    .line 52
    :cond_f
    invoke-virtual {p0, p1, v0, p5}, Lcom/qiniu/auth/Client;->execute(Lcom/qiniu/auth/Client$ClientExecutor;Lorg/apache/http/client/methods/HttpRequestBase;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;

    move-result-object v1

    return-object v1
.end method

.method public call(Lcom/qiniu/auth/Client$ClientExecutor;Ljava/lang/String;Lorg/apache/http/HttpEntity;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;
    .registers 12
    .param p1, "client"    # Lcom/qiniu/auth/Client$ClientExecutor;
    .param p2, "url"    # Ljava/lang/String;
    .param p3, "entity"    # Lorg/apache/http/HttpEntity;
    .param p4, "ret"    # Lcom/qiniu/auth/CallRet;

    .prologue
    .line 37
    invoke-interface {p3}, Lorg/apache/http/HttpEntity;->getContentType()Lorg/apache/http/Header;

    move-result-object v6

    .line 38
    .local v6, "header":Lorg/apache/http/Header;
    const-string v3, "application/octet-stream"

    .line 39
    .local v3, "contentType":Ljava/lang/String;
    if-eqz v6, :cond_c

    .line 40
    invoke-interface {v6}, Lorg/apache/http/Header;->getValue()Ljava/lang/String;

    move-result-object v3

    :cond_c
    move-object v0, p0

    move-object v1, p1

    move-object v2, p2

    move-object v4, p3

    move-object v5, p4

    .line 42
    invoke-virtual/range {v0 .. v5}, Lcom/qiniu/auth/Client;->call(Lcom/qiniu/auth/Client$ClientExecutor;Ljava/lang/String;Ljava/lang/String;Lorg/apache/http/HttpEntity;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;

    move-result-object v0

    return-object v0
.end method

.method protected execute(Lcom/qiniu/auth/Client$ClientExecutor;Lorg/apache/http/client/methods/HttpRequestBase;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;
    .registers 5
    .param p1, "client"    # Lcom/qiniu/auth/Client$ClientExecutor;
    .param p2, "httpRequest"    # Lorg/apache/http/client/methods/HttpRequestBase;
    .param p3, "ret"    # Lcom/qiniu/auth/CallRet;

    .prologue
    .line 64
    invoke-virtual {p1, p2, p3}, Lcom/qiniu/auth/Client$ClientExecutor;->setup(Lorg/apache/http/client/methods/HttpRequestBase;Lcom/qiniu/auth/CallRet;)V

    .line 65
    const/4 v0, 0x0

    new-array v0, v0, [Ljava/lang/Object;

    invoke-virtual {p1, v0}, Lcom/qiniu/auth/Client$ClientExecutor;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;

    .line 66
    return-object p1
.end method

.method public get(Lcom/qiniu/auth/Client$ClientExecutor;Ljava/lang/String;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;
    .registers 5
    .param p1, "client"    # Lcom/qiniu/auth/Client$ClientExecutor;
    .param p2, "url"    # Ljava/lang/String;
    .param p3, "ret"    # Lcom/qiniu/auth/CallRet;

    .prologue
    .line 56
    new-instance v0, Lorg/apache/http/client/methods/HttpGet;

    invoke-direct {v0, p2}, Lorg/apache/http/client/methods/HttpGet;-><init>(Ljava/lang/String;)V

    invoke-virtual {p0, p1, v0, p3}, Lcom/qiniu/auth/Client;->execute(Lcom/qiniu/auth/Client$ClientExecutor;Lorg/apache/http/client/methods/HttpRequestBase;Lcom/qiniu/auth/CallRet;)Lcom/qiniu/auth/Client$ClientExecutor;

    move-result-object v0

    return-object v0
.end method

.method public makeClientExecutor()Lcom/qiniu/auth/Client$ClientExecutor;
    .registers 2

    .prologue
    .line 60
    new-instance v0, Lcom/qiniu/auth/Client$ClientExecutor;

    invoke-direct {v0, p0}, Lcom/qiniu/auth/Client$ClientExecutor;-><init>(Lcom/qiniu/auth/Client;)V

    return-object v0
.end method

.method protected roundtrip(Lorg/apache/http/client/methods/HttpRequestBase;)Lorg/apache/http/HttpResponse;
    .registers 4
    .param p1, "httpRequest"    # Lorg/apache/http/client/methods/HttpRequestBase;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 70
    const-string v0, "User-Agent"

    const-string v1, "qiniu android-sdk v6.0.0"

    invoke-virtual {p1, v0, v1}, Lorg/apache/http/client/methods/HttpRequestBase;->setHeader(Ljava/lang/String;Ljava/lang/String;)V

    .line 71
    iget-object v0, p0, Lcom/qiniu/auth/Client;->mClient:Lorg/apache/http/client/HttpClient;

    invoke-interface {v0, p1}, Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse;

    move-result-object v0

    return-object v0
.end method
